% reBuildImage
% ============
% Description	: from a vector image, build a file matrix
% 		  and save it into OUT_DIR directory, if OUT_DIR
%		  doesnt exist it'll be created.
%		  It can be display the output image with the thrird
%		  boolean show parameter.
% Parameters
% ----------
% pattern	: Vector image
% output	: file output name
% show		: boolean value to display image
% 
% RETURN 	: the matrix image
% example	: reBuildImage(patterns{20},"salida.png",true);

function matrix=reBuildImage(pattern,output,show)
	IMG_WIDTH=64;
	for i=1:IMG_WIDTH:columns(pattern);
		matrix(floor(i/IMG_WIDTH)+1,:)=pattern(i:i+IMG_WIDTH-1);
	endfor
%	matrix = (matrix + 1)/2;
	imwrite(matrix,output);
	if(show)
		imshow(imread(output));
	endif
endfunction
